﻿using Autodesk.Revit.UI;
using AutoRevit.Entry.Application;

namespace AutoRevitDemo.Modules;

internal class ModuleA : IExternalModule
{
    public Result OnShutdown(UIControlledApplication application)
    {
        return Result.Succeeded;
    }

    public Result OnStartup(UIControlledApplication application)
    {
        TaskDialog.Show("提示", "加载ModuleA");
        return Result.Succeeded;
    }
}

internal class ModuleB : ExternalModuleBase
{
    private class ModuleB_A() : IExternalModule
    {
        public Result OnShutdown(UIControlledApplication application)
        {
            return Result.Succeeded;
        }

        public Result OnStartup(UIControlledApplication application)
        {
            TaskDialog.Show("提示", "加载ModuleB_A");
            return Result.Succeeded;
        }
    }

    private class ModuleB_B() : IExternalModule
    {
        public Result OnShutdown(UIControlledApplication application)
        {
            return Result.Succeeded;
        }

        public Result OnStartup(UIControlledApplication application)
        {
            TaskDialog.Show("提示", "加载ModuleB_B");
            return Result.Succeeded;
        }
    }

    protected override Result OnStartup(UIControlledApplication application)
    {
        AddModule(new ModuleB_A());
        AddModule(new ModuleB_B());

        TaskDialog.Show("提示", "加载ModuleB");
        return base.OnStartup(application);
    }
}